#!/usr/bin/ksh

###Script to send test emails from a custom domain (AIX sendmail, should work with others)
###Christopher D. DeVille
 
MSG="$1"
MYEMAIL=custom@anydomain.com
MYINFO="Custom Domain"
MAILTO=myuser@email.com
SUBJECT="Just A Test"


fn_sendmail()
{
# Build sendmail header.
print "From: ${MYEMAIL} [${MYINFO}]"
print "To: ${MAILTO}"
print "Reply-to: ${MYEMAIL}"
print "Subject: ${SUBJECT}"
print "X-MSMail-Priority: High"
print "importance: 1"
print "Mime-Version: 1.0"
print "Content-Type: text/plain"

if [[ -n $MSG ]] 
    then print "$(cat $MSG)"
	else print "Hi,\n\tThis is a test.\nThanks\nMe"
fi 
}

# Call sendmail header and pipe to sendmail.
fn_sendmail | sendmail -t -oi
